You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

[...nextauth].ts 865B

123456789101112131415161718192021222324252627282930313233
  1. import { isSponsoringMe } from '-utils/isSponsoringMe'
  2. import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'
  3. import NextAuth from 'next-auth'
  4. import Providers from 'next-auth/providers'
  5. export default function Auth(
  6. req: NextApiRequest,
  7. res: NextApiResponse
  8. ): ReturnType<NextApiHandler> {
  9. return NextAuth(req, res, {
  10. providers: [
  11. Providers.GitHub({
  12. clientId: process.env.GITHUB_ID,
  13. clientSecret: process.env.GITHUB_SECRET,
  14. scope: 'read:user',
  15. }),
  16. ],
  17. callbacks: {
  18. async redirect(url, baseUrl) {
  19. return baseUrl
  20. },
  21. async signIn(user, account, profile: { login?: string }) {
  22. const canLogin = await isSponsoringMe(profile?.login)
  23. if (canLogin) {
  24. return canLogin
  25. } else {
  26. return '/sponsorware'
  27. }
  28. },
  29. },
  30. })
  31. }